package com.fjnu.dto;

/**
 * 统一响应结果封装类
 */
public class ResponseResult<T> {
    private boolean success;  // 是否成功
    private String message;   // 响应消息
    private T data;           // 响应数据

    public ResponseResult() {}

    public ResponseResult(boolean success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    // 成功响应静态方法
    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(true, "操作成功", data);
    }

    // 失败响应静态方法
    public static <T> ResponseResult<T> error(String message) {
        return new ResponseResult<>(false, message, null);
    }

    // Getter和Setter
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}